import request from '@/utils/request'
import type { MenuListResponseData, MenuParams } from './type'

enum API {
  GETMENULIST_URL = '/admin/acl/permission',
  ADDMENU_URL = '/admin/acl/permission/save',
  UPDATEMENU_URL = '/admin/acl/permission/update',
  REMOVEMENU_URL = '/admin/acl/permission/remove/'
}

// 获取菜单列表
export const getMenuListService = () =>
  request.get<any, MenuListResponseData>(API.GETMENULIST_URL)

// 添加菜单
export const addMenuService = (data: MenuParams) =>
  request.post<any, any>(API.ADDMENU_URL, data)

// 更新菜单
export const updateMenuService = (data: MenuParams) =>
  request.put<any, any>(API.UPDATEMENU_URL, data)

// 删除菜单
export const removeMenuService = (id: number) =>
  request.delete<any, any>(API.REMOVEMENU_URL + id)
